Subroutine to calculate the best match unit over the grid
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(self_organizing_map) | :: | kohonen_map |
A |
|||
type(kohonen_pattern), | intent(inout), | dimension(:) | :: | input_data |
A |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | nx | ||||
integer, | public | :: | ny | ||||
integer, | public | :: | nz | ||||
integer, | public | :: | ix | ||||
integer, | public | :: | iy | ||||
integer, | public | :: | iz | ||||
integer, | public | :: | ihit | ||||
integer, | public | :: | jhit | ||||
integer, | public | :: | khit | ||||
integer, | public | :: | idat | ||||
integer, | public | :: | pat_hit | ||||
type(kohonen_prototype), | public | :: | current_prototype | ||||
real(kind=wp), | public | :: | dist | ||||
real(kind=wp), | public | :: | dist_min |
subroutine find_bmu_grid(kohonen_map,input_data) !======================================================================================== !! Subroutine to calculate the best match unit over the grid class(self_organizing_map) :: kohonen_map !! A `self_organizing_map` object type(kohonen_pattern),dimension(:),intent(inout) :: input_data !! A `kohonen_pattern` array with the input data integer :: nx,ny,nz,ix,iy,iz,ihit,jhit,khit,idat,pat_hit type(kohonen_prototype) :: current_prototype real(kind=wp) :: dist,dist_min ! do idat=1,size(input_data) dist_min=1.0e7;ihit=0;jhit=0;khit=0; call input_data(idat)%get(current_prototype); !$OMP parallel do do iz=1,size(kohonen_map%grid,3) do iy=1,size(kohonen_map%grid,2) do ix=1,size(kohonen_map%grid,1) dist=kohonen_map%grid(ix,iy,iz)%distance(current_prototype,kohonen_map%distance_function); dist = dist/float(kohonen_map%parameters%number_variables) if(dist < dist_min) then dist_min=dist; ihit=ix;jhit=iy;khit=iz;pat_hit=idat; endif enddo enddo enddo !$OMP end parallel do kohonen_map%grid_pattern_index(ihit,jhit,khit)=pat_hit; kohonen_map%cells_index(idat,1)=ihit; kohonen_map%cells_index(idat,2)=jhit; kohonen_map%cells_index(idat,3)=khit; ! write(*,*) 'BMU= ',idat,ihit,jhit,khit,dist_min enddo ! ! end subroutine find_bmu_grid